package com.ysh.contentcenter.feignclient.fallbackFactory;

import com.ysh.contentcenter.domain.dto.user.UserDTO;
import com.ysh.contentcenter.feignclient.UserCenterFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class UserCenterFeignClientFactory implements FallbackFactory<UserCenterFeignClient> {
    @Override
    public UserCenterFeignClient create(Throwable throwable) {
        return new UserCenterFeignClient() {
            @Override
            public UserDTO findById(Integer id) {
                log.error("远程调用被限流或降级了",throwable);
                UserDTO userDTO=new UserDTO();
                userDTO.setWxNickname("流控后设置的用户");
                return userDTO;
            }
        };
    }
}
